package org.protester.core;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;

import org.protester.base.Content;

/**
 * Classe que define um protesto
 * 
 * @author fernandojr.ifcg@live.com
 */
@Entity
public class Protest extends Content {

	@Embedded()
	private Location location;

	@ElementCollection
	@Column(name = "link")
	private Set<String> links = new HashSet<String>();

	@ManyToMany(cascade = CascadeType.PERSIST)
	@JoinTable(inverseJoinColumns = @JoinColumn(name = "tag_id"))
	private Set<Tag> tags = new HashSet<Tag>();

	@ManyToMany(cascade = CascadeType.PERSIST)
	@JoinTable(inverseJoinColumns = @JoinColumn(name = "category_id"))
	private Set<Category> categories = new HashSet<Category>();

	@ManyToMany(cascade = CascadeType.PERSIST)
	@JoinTable(inverseJoinColumns = @JoinColumn(name = "image_id"))
	private Set<Image> images = new HashSet<Image>();

	public Protest() {
	}

	/**
	 * Cria um novo protesto
	 * 
	 * @param title
	 *            O titulo do protesto
	 * @param description
	 *            A descricao do protesto
	 * @param location
	 *            A localizacao do lugar da qual o proteste refere-se.
	 */
	public Protest(String title, String description, Location location) {
		super(title, description);
		this.setLocation(location);
	}

	public String getContent() {
		return "TODO"; // TODO
	}

	public void setLocation(Location location) {
		this.location = location;
	}

	public Location getLocation() {
		return location;
	}

	public Set<String> getLinks() {
		return links;
	}

	public void setLinks(Set<String> links) {
		this.links = links;
	}

	public Set<Tag> getTags() {
		return tags;
	}

	public void setTags(Set<Tag> tags) {
		this.tags = tags;
	}

	public void setCategories(Set<Category> categories) {
		this.categories = categories;
	}

	public Set<Category> getCategories() {
		return categories;
	}

	public Set<Image> getImages() {
		return images;
	}

	public void setImages(Set<Image> images) {
		this.images = images;
	}

	@Override
	public String toString() {
		return super.toString() + " Protest [location=" + location + ", links="
				+ links + ", tags=" + tags + ", categories=" + categories
				+ ", images=" + images + "]";
	}

}